<?php

class dish_info{
public function index(){
$menu_id = intval($GLOBALS['request']['menu_id']);
if(empty($menu_id)){
$root['info']='您菜名不存在！';
output($root);
}
$dish_info=  $GLOBALS['db']->getRow('SELECT slm.supplier_location_id as supplier_id,sl.name as supplier_name,sl.avg_point,slm.name as menu_name,slm.brief,slm.price,slm.cate_id,slm.preview,slm.is_special,slm.collect_nums,sl.deal_cate_id  FROM '.DB_PREFIX.'supplier_location_menu as slm left join '.DB_PREFIX."supplier_location as sl on slm.supplier_location_id=sl.id  WHERE  slm.id='{$menu_id}' ");
$dish_info['avg_point']=round($dish_info['avg_point'],1);
$dish_info['image']=get_abs_img_root(get_spec_image($dish_info['preview'],400,240,1));
$dish_info['price']='￥'.round($dish_info['price'],1);
$dish_info['group_point'] = $GLOBALS['db']->getAll('select id,name from '.DB_PREFIX.'point_group as pg left join '.DB_PREFIX.'point_group_link as pgl on pg.id = pgl.point_group_id  where pgl.category_id = '.$dish_info['deal_cate_id'].' order by sort asc');
foreach($dish_info['group_point'] as $kk=>$vv)
{
$dish_info['group_point'][$kk]['avg_point'] =  round(floatval($GLOBALS['db']->getOne('select avg_point from '.DB_PREFIX.'supplier_location_point_result where supplier_location_id = '.$dish_info['supplier_id'].' and group_id = '.$vv['id'])),1);
}
$dish_info['other']= $GLOBALS['db']->getAll('SELECT id,name,price,preview,collect_nums  FROM '.DB_PREFIX."supplier_location_menu where is_special=1 and supplier_location_id='{$dish_info['supplier_id']}' ");
foreach($dish_info['other'] as $ok=>$ov)
{
$dish_info['other'][$ok]['price']='￥'.round($ov['price'],1);
$dish_info['other'][$ok]['image']=get_abs_img_root(get_spec_image($ov['preview'],400,240,1));
if(empty($ov['preview']))
{
$dish_info['other'][$ok]['image']='';
}
unset($dish_info['other'][$ok]['preview']);
}
unset($dish_info['deal_cate_id'],$dish_info['is_special'],$dish_info['cate_id'],$dish_info['preview']);
$root=array();
$root=$dish_info;
output($root);
}
}

?>